/**
 * 
 */
package com.ketayao.utils;

import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;

import com.ketayao.ketacustom.entity.main.User;
import com.ketayao.ketacustom.service.UserService;
import com.ketayao.ketacustom.shiro.ShiroUser;

/**
 * @author KETAYAO
 *
 */
public abstract class SecurityUtils {
	
	@Autowired
	private static UserService userService;
	
	public static User getLoginUser() {
		User user = userService.getByUsername(getSubject().getPrincipal().toString());
		return user;
		//return getShiroUser().getUser();
	}
	
	public static ShiroUser getShiroUser() {
		Subject subject = getSubject();
		ShiroUser shiroUser = (ShiroUser)subject.getPrincipal();
		return shiroUser;
	}

	public static Subject getSubject() {
		return org.apache.shiro.SecurityUtils.getSubject();
	}
}
